home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Merciful 2
/
Merciful - Disc 2.iso
/
software
/
i
/
ian'simagineutilsv1.3.lha
/
IIUtilities
/
StageFrames
< prev
next >
Wrap
Text File
|
1995-01-14
|
7KB
|
157 lines
/*\
*
* This ARexx script increases the number of frames in an animation
* and scales the bars automaticly to fit the new animation length.
* Produces a smoother and younger looking animation. :-)
*
* Usage: StageExpand <stageFileName> <multiplier> [EXPAND]
* stageFileName is renamed to stageFileName.old for backup.
* Multiplier should be a whole number greater than one.
* It tells the script how many times to enlarge your staging
* file. A two will double the number of frames, a three will
* tripple them.
* EXPAND is an optional but important switch. Normally a bar with
* a size of one frame is meant to be a cut. Expanding it would
* give strange results. For instance, take the timeline below...
*
* Frame 1 ... 10 ... 20 21 ... 30
* Position: ######### ## #########
*
* In this, the object stops at frame 10, and at frame 20 it jumps
* and then moves from 21 to 30. If the single frame at 20 were
* to be expanded, it would stop at 10 and at frame 20, MOVE from
* it's position at 10 to the new position at 20 and then move again
* as it follows the third bar. In this (and most) cases you want a
* single bar to stay single. But sometimes you might want the
* script to expand them anyway. Include the EXPAND keyword at the
* end expand single frames. Note that the first bar in a row of
* bars will not be expanded since the first bar should always be a
* single frame. How do you tween a position with no start?
*
* Notes:
* Each object is given a line of its own in the output. A "." is
* displayed for each timeline bar that is modified.
* This script is good for increasing animation lengths, obviously.
* Sometimes you just want to make that 1 second flying logo into
* a 3 second logo easily. But even beter is for doing motion
* blur. Use a value of 8 to increase the length 8x times and then
* use an image processing program to merge the frames. The way I
* think of motion bluring is to consider each set of 8 frames to be
* a single frame. The camera shutter opens at frame 1, and closes
* at frame 8, to repeat with the next group of 9 to 16.
* You can not reduce the animation length with this program. I
* thought about it, but a problem comes up when you have a long row
* or even just two 1 frame action bars. What to do.. merge them?
* Randomly delete one tor two or more? Depending on how the anim
* was set up, merging might work, or make a big mess. If you really
* want to reduce an animation size you can use the range command to
* generate a subset. The problem is that does not always produce a
* smooth animation. If you want to cut an animation dowm from 30
* to 15 you simply render every 2nd frame. But if you want a 20
* frame anim instead, you have to render every 2.5 frames. So when
* you approximate and render frame 3 instead of 2.5, you get a jump
* in the anim. The solution is to expand the animation. In the
* above example, just expand it to a 60 frame animation and render
* every 3rd frame. That way it results in a nice, smooth animation.
* The ReduceFrames can be used to figure out the smallest amount you
* can increase the animation to and get a smooth animation. If you
* wanted to turn a 30 frame anim into a 24 frame anim, use ReduceFrames
* and it will tell you to expand the anim by a factor of four and
* render every 4th frame.
* I hope that was clear. I'm a programmer not an english major. :)
*
* V1.0 Nov-22-94
* IanSmith@moose.erie.net
*
\*/
Numeric Digits 14 /* Need at least 12 to handle 32 bits */
Parse Arg FileName Change ExpandToggle .
If Change="" Then Do
Say "Usage: StageExpand <stageFileName> <multiplier> [EXPAND]"
Say " More help can be found in the header of this file."
Exit
End
If Upper(ExpandToggle)="EXPAND" Then Expand=1; Else Expand=0
MaxFrames=0
Temp="Temp$Stage."||Date(D)||Time(S) /* Create temp filename */
Address Command 'Delete >NIL:' FileName||".Old" /* Erase backup file */
If Open(Out,Temp,"W")=0 Then Do
Say "Can't open temp staging file!"
Exit
End
If Open(In,FileName,"R")=0 Then Do
Say "Can't find '"FileName"' to open!"
Exit
End
Call Open(Text,"*","W")
Call WriteCH(Text,"Multiplying '"||FileName||"' by "||Change)
Call ParseStaging(C2D(SubStr(ReadWrite(In,12),5,4)))
Call WriteLN(Text,"") Close(In) Close(Out) Close(Text)
Address Command 'Rename' FileName 'To' FileName||".Old"
Address Command 'Rename' Temp 'To' FileName
Exit
ParseStaging: PROCEDURE EXPOSE Change Expand MaxFrames
Parse Arg MaxSize /* Recursive Function */
TotalSize=4; New=0
Do Until TotalSize>=MaxSize /* Read MaxSize Bytes */
LastName=Name
Name=ReadWrite(In,4)
If Name~=LastName Then New=0
Size=C2D(ReadWrite(In,4))
If Size//2=1 Then Size=Size+1 /* Add pad byte if needed */
If Name="ISTG" | Name="SOBJ" Then Do
TotalSize=TotalSize+ParseStaging(Size)+8 /* Parse into these hunks */
Iterate
End
TotalSize=TotalSize+Size+8 /* Add SIZE and NAME length */
If Name="NAME" Then Do
Call WriteCH(Text,'0A'x||"Expanding "||ReadWrite(In,Size))
LastSF=-1; LastEF=-2
End; Else If Name="MAXF" Then Do
MaxFrames=C2D(ReadCH(In,Size))*Change
Call WriteCH(Out,Right(D2C(MaxFrames),2,'00'x))
LastSF=-1; LastEF=-2;
End; Else If Index("LOOP-NAME-STGF-LYR0", Name)=0 Then Do
Call WriteCH(Text,".")
Buffer=ReadCH(In,Size)
StartF=C2D(SubStr(Buffer,3,2))
EndF=C2D(SubStr(Buffer,5,2))
If (StartF>0 & StartF<=MaxFrames & EndF>0 & EndF<=MaxFrames & StartF<=EndF) Then Do
If (EndF-StartF=0) & (Expand=0 | New=0) Then Do /* If single... */
NewStartF=StartF*Change-(Change-1) /* ..don't expand */
NewEndF=EndF*Change-(Change-1)
End; Else Do
If (LastEF-LastSF=0 & LastEF+1=StartF) & (Expand=0 | New=1) Then
NewStartF=StartF*Change-(Change-1)*2
Else
NewStartF=StartF*Change-(Change-1) /* ...expand */
If EndF=1 Then
NewEndF=1
Else
NewEndF=EndF*Change
End
Buffer=Overlay(Right(D2C(NewStartF),2,'00'x),Buffer,3)
Buffer=Overlay(Right(D2C(NewEndF),2,'00'x),Buffer,5)
LastSF=StartF; LastEF=EndF; New=New+1
End; Else Do
Say "Hunk" Name "is not a valid timeline!"
LastSF=-1; LastEF=-2
End
Call WriteCH(Out,Buffer)
End; Else Do
Call ReadWrite(In,Size)
LastSF=-1; LastEF=-2
End
End
Return TotalSize
ReadWrite: /* This reads staging data, */
Parse Arg FileHandle , Bytes . /* writes it to the new file */
RWBuffer=ReadCH(FileHandle, Bytes) /* and returns the data. */
Call WriteCH(Out,RWBuffer)
Return RWBuffer